package com.bawei.library_common.utils

import android.content.Context
import android.widget.ImageView
import com.bawei.library_image.ImageCrop
import com.bawei.library_image.ImageLoaderManager
import com.bawei.library_image.ImageOptions
import com.bawei.library_image.ImageStrategy

/**
 * @Author : yaotianxue
 * @Time : On 2023/6/20 15:52
 * @Description : ImageUtils
 */
class ImageUtils {
    companion object{

        var imageLoaderManager = ImageLoaderManager(ImageStrategy.Glide)

        var imageOptions = ImageOptions.Builder()
//            .setErrorImage()
//            .setPlaceImage()
            .setImageSize(arrayOf(400,400))//图片压缩比例，避免内存溢出
            .setStaticImage(true)
            .setSkipDiskCache(true)
            .setSkipMemoryCache(true)
            .build()

        fun loadIntoImageView(context: Context,source:Any, target: ImageView){
            imageOptions.imageCrop = ImageCrop.CENTER
            imageLoaderManager.loadIntoImageView(context,source,target,imageOptions)
        }

        fun loadCircleIntoImageView(context: Context,source:Any, target: ImageView){
            imageOptions.imageCrop = ImageCrop.CIRCLE
            imageLoaderManager.loadIntoImageView(context,source,target,imageOptions)
        }

        fun loadRoundedIntoImageView(context: Context,source:Any, target: ImageView){
            imageOptions.imageCrop = ImageCrop.ROUNDED
            imageLoaderManager.loadIntoImageView(context,source,target,imageOptions)
        }



    }
}